package com.bjc.principle.simplefactory.order;

import com.bjc.principle.simplefactory.pizza.GreekPizza;
import com.bjc.principle.simplefactory.pizza.Pizza;

/**
 * @program: DesignPattern
 * @description: 简单工厂类
 * @author: bjc
 * @create: 2020-12-16 20:09
 */
public class SimpleFactory {

    //根据orderType返回对应的Pizza对象
    public Pizza createPizza(String orderType){
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if (orderType.equals("greek")){
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        }else if (orderType.equals("cheese")){
            pizza = new GreekPizza();
            pizza.setName("奶酪披萨");
        }
        return pizza;
    }
}
